package com.mindcraft.user.serivce.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mindcraft.user.mapper.McUserMapper;
import com.mindcraft.user.mapper.UserMapper;
import com.mindcraft.user.po.McUser;
import com.mindcraft.user.serivce.XcxService;
import com.mindcraft.user.vo.UserLoginVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class XcxServiceImpl extends ServiceImpl<McUserMapper, McUser> implements XcxService {

    @Autowired
    private UserMapper userMapper;
    @Override
    public McUser getByOpenid(String openId) {
        return userMapper.selectOne(new QueryWrapper<McUser>().eq("open_id", openId));
    }


    @Override
    public UserLoginVo getUserLoginVo(String userId) {
        UserLoginVo userLoginVo = new UserLoginVo();
        McUser user = this.getById(userId);
        userLoginVo.setNickName(user.getNickname());
        userLoginVo.setUserId(userId);
        userLoginVo.setPhotoUrl(user.getUserpic());
        userLoginVo.setOpenId(user.getOpenId());


        return userLoginVo;
    }
}
